package com.stanford.report;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import com.stanford.data.DataUtil;
import com.stanford.data.User;

/**
 * Prints the analysis results in a file
 * 
 * @author Fatih Sunor
 */
public class Report {
	
	private static final String STARS = "*************************************************************\n";
	private static final String FATIH_SUNOR = "Classification Algorithms - Fatih Sunor\n";

	/**
	 * @param args is a path to the data containing file
	 * @throws IOException if the file is missing
	 */
	public static void main(String[] args) throws IOException {
		Map<String, List<User>> userData = DataUtil.buildData(args[0]);
		String report = STARS;
		report = report + FATIH_SUNOR;
		FileWriter fstream = new FileWriter("Report");
		BufferedWriter out = new BufferedWriter(fstream);
		out.write(report);
		for(String webSite: userData.keySet()){
			List<User> users = userData.get(webSite);
			out.write(Basic.report(users, webSite));
			out.write(Basic.reportCorrelations(users, webSite));
			out.write(MachineLearning.reportSVM(users, webSite));
 			out.write(MachineLearning.reportNaiveBayes(users, webSite));
		}
		out.close();
	}
}
